package com.gtgj.widget.model;


import com.gtgj.widget.calender.GTLunarCalendarV2;
import com.gtgj.widget.util.DateUtils;
import com.gtgj.widget.util.TextUtils;

import java.util.Calendar;


public class DateInfo {
    private long date ;
    private boolean todayKaiShou = false;//是否显示今日开售
    private boolean yueQiangFlagShow;//是否显示"约抢"

    public boolean isYueQiangFlagShow() {
        return yueQiangFlagShow;
    }

    public void setYueQiangFlagShow(boolean yueQiangFlagShow) {
        this.yueQiangFlagShow = yueQiangFlagShow;
    }

    public long getDate() {
        return date;
    }

    public boolean isTodayKaiShou() {
        return todayKaiShou;
    }

    public void setTodayKaiShou(boolean todayKaiShou) {
        this.todayKaiShou = todayKaiShou;
    }

    //阳历日期
    public String getSolarText() {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(date);
        return calendar.get(Calendar.DAY_OF_MONTH) + "";
    }

    //阴历日期
    public String getLunarText() {
        int[] yearMonthDay = getYearMonthDay();
        String getDateNL = GTLunarCalendarV2.GetDateNL(yearMonthDay[0], yearMonthDay[1] + 1, yearMonthDay[2]);// 普通农历
        String specialDay = GTLunarCalendarV2.getBarelyHoliday(yearMonthDay[0], yearMonthDay[1] + 1, yearMonthDay[2]);// 特殊节日
        return TextUtils.isEmpty(specialDay) ? getDateNL.substring(getDateNL.indexOf("月") + 1) : specialDay;
    }

    public void setDate(long date) {
        this.date = date;
    }

    public String getWeekText() {
        return GTLunarCalendarV2.getWeekDay(date);
    }

    public String getTitleDate() {
        return DateUtils.M().format(date);
    }


    public int[] getYearMonthDay() {
        int infos[] = new int[3];
        Calendar calendar = ((Calendar) Calendar.getInstance().clone());
        calendar.setTimeInMillis(date);
        int year = calendar.get(Calendar.YEAR);
        infos[0] = year;
        int month = calendar.get(Calendar.MONTH);
        infos[1] = month;
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        infos[2] = day;
        return infos;
    }

    @Override
    public String toString() {
        return "DateInfo{" +
                "date=" + date +
                ", todayKaiShou=" + todayKaiShou +
                ", yueQiangFlagShow=" + yueQiangFlagShow +
                '}';
    }
}
